package com.ben.multiple.elasticsearch.resource;

import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClientBuilder;
import org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
public class CustomRestClientBuilderCustomizer implements RestClientBuilderCustomizer, Ordered {

    @Override
    public void customize(RestClientBuilder builder) {

    }

    @Override
    public void customize(HttpAsyncClientBuilder builder) {

    }

    @Override
    public void customize(RequestConfig.Builder builder) {
        builder.setSocketTimeout(60000)
                .setConnectTimeout(10000)
                .setConnectionRequestTimeout(600000);
    }

    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE;
    }
}